<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>图片切换</title>
	</head>
	<body>
		<img id="img" src="./img/work1/1.jpg" > 
		<input type="button" name="" id="" value="点击切换" onclick="imgspawn(event)" />
	</body>
	<script type="text/javascript">
	
		function imgspawn(event){
				var imgall=document.getElementById('img');
				event.target.value='开始切换';
				
				// setTimeout(function(){
				// 	var rand= Math.ceil(Math.random()*1000000000%9);
				// 	console.log(rand);
				// 	imgall.src='./img/work1/'+rand+'.jpg';
				// },1000)
				
				setInterval(function(){
					var rand= Math.ceil(Math.random()*1000000000%9);
					console.log(rand);
					imgall.src='./img/work1/'+rand+'.jpg';
					
				},10)
	
				
			
		}
		
		
	
		
		
	</script>
</html>
